package dmmm.components;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class KMOPR extends LogicalComponent {		//@Darko

    private ArrayList<Integer> stepsDec;

    public KMOPR() {
        super(57, 1, false);
        out[0].setIsInt();

        stepsDec=new ArrayList<Integer>();
        int counter = 0;
        BufferedReader reader=null;
        try {
            reader = new BufferedReader(new FileReader("conf/dmmm/kmopr.txt"));
            String line;
            while ((line = reader.readLine()) != null) {
                
            	stepsDec.add(counter++, Integer.parseInt(line));
            }
        } catch (Exception e) {
        	e.printStackTrace();
        }finally{
        	if(reader!=null)
				try {
					reader.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
        }

    }

    public void func() {
        int i = 0;
        for (; i < in.length; i++) {
            if (in[i].getBoolVal()) {
                break;
            }
        }
        if(i<in.length)out[0].setIntVal(stepsDec.get(i));
    }
}
